package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jk.smartelderlycare.dao.TbUserMapper;
import com.jk.smartelderlycare.dto.TbUser;
import com.jk.smartelderlycare.service.TbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author hhk
 * @version 1.0
 * @ClassName TbUserServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/18 20:29
 */
@Service
public class TbUserServiceImpl implements TbUserService {
    @Autowired
    private TbUserMapper tbUserMapper;
    /** 
     * @description: 通过用户名获得用户信息
     * @param: [username]
     * @return: com.jk.smartelderlycare.dto.TbUser
     * @author hhk
     * @date: 2024/11/18 20:30
     */ 
    @Override
    public TbUser findTbUserByUsername(String username) {
        QueryWrapper<TbUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",username);
        TbUser tbUser = tbUserMapper.selectOne(queryWrapper);
        if(Objects.isNull(tbUser)){
            throw new RuntimeException("用户名不存在");
        }
        return tbUser;
    }



}
